package cn.wubo.soap;

import cn.wubo.soap.model.Book;
import cn.wubo.soap.model.BookRequest;
import cn.wubo.soap.model.BookResponse;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Import;

@Import(SoapConfig.class)
@SpringBootApplication
public class SoapApplication {

    public static void main(String[] args) {
        SpringApplication.run(SoapApplication.class, args);
    }

    @Bean
    CommandLineRunner lookup(SOAPConnector soapConnector) {
        return args -> {
            BookRequest request = new BookRequest();
            Book book = new Book();
            book.setName("BBBBB");
            request.setBook(book);
            BookResponse response =(BookResponse) soapConnector.callWebService("http://localhost:8080/service/book", request);
            System.out.println("Got Response");
            System.out.println("name : "+response.getBook().getName());
            System.out.println("sn : "+response.getBook().getSn());
            System.out.println("price : "+response.getBook().getPrice());
        };
    }
}
